#include "unmountVFS.h"
char* unmountVFS(char *fileName)
{
	if(mh==NULL)
		return ERR_VFS_UNMOUNT_04;
	if(strcmp(fileName, mh->fileSystemLabel)!=0)
		return ERR_VFS_UNMOUNT_01;
	FILE *fp=fopen(fileName,"r+b");
	if(fp==NULL)
		return ERR_VFS_UNMOUNT_01;
	rewind(fp);
	int maxFileDescriptors=mh->maxDescriptors;
	int currentFileDesc=mh->countOfFileDescriptors;
	int noOfBlocks=maxFileDescriptors/2;
	int check=-1;
	fwrite(mh,sizeof(meta),1,fp);
	fwrite(h->desc,sizeof(descriptors)*maxFileDescriptors,1,fp);
	fwrite(h->freeList,sizeof(char)*noOfBlocks,1,fp);
	fseek(fp,sizeof(meta)+sizeof(descriptors)*maxFileDescriptors+sizeof(char)*noOfBlocks+maxBlockSize*(noOfBlocks-1),SEEK_SET);
	fwrite(arr,sizeof(arr),1,fp);
	check=0;
	//fclose(fp);
	mh=NULL;
	h->desc=NULL;
	h->freeList=NULL;
	h=NULL;
	arr=NULL;
	/*free(mh);
	free(h);
	free(arr);*/
	if(check==0)
		return "SUCCESS";
	else
		return ERR_VFS_UNMOUNT_02;
}
